<?php
Class CMySQL{
   var $mysql;
   var $errorno;
   function CMySQL($dbserver,$dbuser,$dbpsd,$dbname)
   {
      $this->mysql = mysql_connect ($dbserver, $dbuser, $dbpsd);
      $result = mysql_list_tables($dbname);
     // mysql_set_charset('UTF-8', $this->mysql);
   }
   function DoQuery($SQL)
   {
      if($this->mysql!=FALSE) 
      {
         
         $result = mysql_query($SQL,$this->mysql);// or die("Sorry,register failed : " .  mysql_error());
         if(!$result) $this->errorno=mysql_errno();
         $data=Array();
         while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
         {
            $data[]=$line;
         }
         return($data);
      }
      else { return "" ;}
   }

   function DoQueryNoReturn($SQL)
   {
      if($this->mysql!=FALSE) 
      {
         mysql_query($SQL,$this->mysql);
         $this->errorno= mysql_errno();
      }
   }

   function GetErrorNo()
   {
      return $this->errorno;
   }
   function GetErrorString()
   {
      return mysql_error();
   }
   function GetLastId()
   {
      if($this->mysql!=FALSE)
      {
         return mysql_insert_id();
      }
   }
   function GetAffectedId()
   {
      if($this->mysql!=FALSE)
      {
         return mysql_affected_rows();
      }
   }

   function Close()
   {
      mysql_close($this->mysql);
   }
}
?>